package com.gem.growingtree.activity;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

public class ChangeNickname extends Activity {
	
	private Button savebButton;
	private Button saveSuccessButton;
	private EditText newNickname;
	private TextView nickname;
	private TextView changeNickname;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_change_nickname);
		savebButton = (Button) findViewById(R.id.save);
		saveSuccessButton = (Button) findViewById(R.id.save_success);
		newNickname = (EditText) findViewById(R.id.new_nickname);
		nickname = (TextView) findViewById(R.id.nick_name);
		changeNickname = (TextView) findViewById(R.id.nicknameback);
		changeNickname.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				Intent intent = new Intent();
				intent.setClass(ChangeNickname.this, MyInformationActivity.class);
				startActivity(intent);
			}
		});
	}

	public void saveNickname(View view) {
		String nickName = newNickname.getText().toString();
		if (nickName == null) {
			Toast.makeText(this, "昵称不可为空", 0).show();
		}else {
			view.setVisibility(R.id.save_success);
		}
	}
	
	public void saveSuccess(View view) {
		String nickString = newNickname.getText().toString();
		nickname.setText(nickString);
		Intent intent = new Intent();
		intent.setClass(ChangeNickname.this, MyInformationActivity.class);
		startActivity(intent);
	}
	
	public void back(View view) {
		Intent intent = new Intent();
		intent.setClass(ChangeNickname.this, MyInformationActivity.class);
		startActivity(intent);
	}

}
